package com.dgut.usermanager.service;

import com.dgut.usermanager.dao.UserDao;
import com.dgut.usermanager.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class UserServiceImp implements UserService{
    @Autowired
    UserDao userDao;


    public UserServiceImp() {
        super();
    }

    @Override
    public Optional<User> findUserById(Integer id) {
        return userDao.findById(id);
    }

    @Override
    public List<User> findAllUser() {
        return userDao.findAll();
    }

    @Override
    public User findUserByUsername(String username) {
        return userDao.findUserByUsername(username);
    }

    @Override
    public void deleteUserById(Integer id) {
        userDao.deleteById(id);
    }

    @Override
    public User updateUser(User user) {
        return userDao.save(user);
    }

    @Override
    public User AddUser(User user) {
        return userDao.save(user);
    }
}
